<?php 
if(!isset($_SESSION)) 
	{ 
		session_start(); 
	}
$lang = $_SESSION['lang'];
if (empty($lang) || $lang == "EN") {
	include "../../value/value_en.php";
} else if($lang == "VN") {
	include "../../value/value_vn.php";
}
else {
	include "../../value/value_kr.php";
}
include '../../generallibraries/funcs.php';
include '../../operations/connection.php';

if(isset($_REQUEST['newname'])){
	if($_REQUEST['newname']!=""){
		if($_SESSION['thucthi']=="new"){
			$hamsort=" where LOWER(trim(ac_customer.CustomerName))=LOWER(trim('".$_REQUEST['newname']."'))";
			$sqlCustomer = generalFunctions::listCustomer("ac_customer.CustomerName",$hamsort);
			//echo $sqlCustomer;
			$rs=mysql_query($sqlCustomer);
			if(mysql_num_rows($rs)>0){
				$_SESSION['checknamecus']=$l_companynameexit;
				?>
				<input type="hidden" id="lienngo" value="<?=$_SESSION[checknamecus]?>"/>
				<?php 
				echo $_SESSION['checknamecus'];
			}else{
				//echo $sqlCustomer;
				$_SESSION['checknamecus']="okk";
				?>
				<input type="hidden" id="lienngo" value="<?=$_SESSION[checknamecus]?>"/>
				<?php 
			}
		}else if($_SESSION['thucthi']=="updel"){
			if(isset($_REQUEST['idcus'])){
				$hamsort=" where LOWER(trim(ac_customer.CustomerName))=LOWER(trim('".$_REQUEST['newname']."')) and ac_customer.CustomerID!='".$_REQUEST['idcus']."'";
				$sqlCustomer = generalFunctions::listCustomer("ac_customer.CustomerName",$hamsort);
				$rs=mysql_query($sqlCustomer);
				if(mysql_num_rows($rs)>0){
					$_SESSION['checknamecus']=$l_companynameexit;
					?>
					<input type="hidden" id="lienngo" value="<?=$_SESSION[checknamecus]?>"/>
					<?php 
					echo $_SESSION['checknamecus'];
				}else{
					//echo $sqlCustomer;
					$_SESSION['checknamecus']="okk";
					?>
					<input type="hidden" id="lienngo" value="<?=$_SESSION[checknamecus]?>"/>
					<?php 
				}
			}else{
				$_SESSION['checknamecus']="noid";
				?>
				<input type="hidden" id="lienngo" value="<?=$_SESSION[checknamecus]?>"/>
				<?php 
			}
		}else{
			$_SESSION['checknamecus']="unknow";
			?>
			<input type="hidden" id="lienngo" value="<?=$_SESSION[checknamecus]?>"/>
			<?php 
		}
	}else{
		$_SESSION['checknamecus']="null";
		?>
		<input type="hidden" id="lienngo" value="<?=$_SESSION[checknamecus]?>"/>
		<?php 
	}
}

mysql_close($connection);
?>